<include file="../header" />
<style>
    .keyword-input{
        margin-top: 1rem;
    }
    .keyword-btn{
        margin-top: 0.5rem;
        width: 120px;
        float: left;
    }
    .kw-btn{
        width: 50px;
    }
    .shut-down{
        width: 12px;
        height: 12px;
        position: relative;
        left: -0.5rem;
        top: -0.9rem;
        cursor: pointer;
    }
</style>
<script type="text/javascript" src="/Template/js/vue.min.js"></script>

<body class="J_scroll_fixed" id="container">
<script type="text/javascript">
    $(function() {

        var app = new Vue({
            el: '#container',
            data: {
                keywordList: []
            },
            methods: {
                remove: function(index) {
                    app.keywordList.splice(index,1);
                }
            }
        })

        $("a.add-keyword").bind("click", function() {

            var code = $(this).prev().find("input").val();
            var keyword = $(this).prev().prev().find("input").val();

            if(keyword == "") {
                alert("关键词不能为空");
                return false;
            }

            if(code == "") {
                alert("编码不能为空");
                return false;
            }

            var data = [];

            data.code = code;
            data.keyword = keyword;

            app.keywordList.push(data);

            $(this).prev().find("input").val("");
            $(this).prev().prev().find("input").val("");

        });

        $("button#upload").click(function(){
            //上传文件
            $.ajaxFileUpload({
                url:"{:U('activity/uploadImage')}",//处理图片脚本
                secureuri :false,
                fileElementId :'fileToUpload',//file控件id
                dataType : 'json',
                success : function (data, status){
                    $("input[name=imageUrl]").val(data);
                    $("img[name=preShow]").attr("src", data);
                },
                error: function(data, status, e){
                    alert(e);
                }
            })

        });

        $("button.btn_submit").click(function() {

            $("form").submit();

        })


    })

</script>
<script type="text/javascript"  src="__TMP__/assets/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript"  src="__TMP__/assets/js/ueditor/ueditor.all.min.js"></script>
<div class="wrap jj">
    <div class="common-form">
        <form method="post" class="form-horizontal J_ajaxForm" action="{:U('finishedProduct/editPost')}">
            <fieldset>
                <input type="hidden" name="id" value="{$info.finished_product_id}" />
                <div class="control-group">
                    <label class="control-label">分类：</label>
                    <div class="controls">
                        <select name="classId">
                            {:getClassSelectOptionHtml($info.class_id, 0)}
                        </select>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">编码：</label>
                    <div class="controls">
                        <input type="text" class="input" name="code" value="{$info.code}">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">品名：</label>
                    <div class="controls">
                        <input type="text" class="input" name="productName" value="{$info.name}">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">品号：</label>
                    <div class="controls">
                        <input type="text" class="input" name="number" value="{$info.number}">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">性能：</label>
                    <div class="controls">
                        <textarea style="height:9rem;" name="function">{$info.function}</textarea>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">适应症：</label>
                    <div class="controls">
                        <textarea style="height:9rem;" name="indication">{$info.indication}</textarea>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">规格：</label>
                    <div class="controls">
                        <input type="text" class="input" name="size" value="{$info.size}">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">单位：</label>
                    <div class="controls">
                        <input type="text" class="input" name="unit" value="{$info.unit}">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">定价：</label>
                    <div class="controls">
                        <input type="text" class="input" name="price" value="{$info.price}">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">供应商：</label>
                    <div class="controls">
                        <input type="text" class="input" name="supplier" value="{$info.supplier}">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">图片:</label>
                    <div class="controls">
                        <input id="fileToUpload" type="file" name="fileToUpload" style="width:170px;">
                        <button type="button" class="btn btn-primary" id="upload">上传</button>
                        <input type="hidden" name="imageUrl" value="{$info.image_url}"/>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">图片预览:</label>
                    <div class="controls">
                        <img src="{$info.image_url}" name="preShow" style="width:200px;height:200px;"/>
                    </div>
                </div>



            </fieldset>
            <div class="form-actions">
                <button type="button" class="btn btn-primary btn_submit">更新</button>
                <a class="btn" href="__URL__">返回</a>
            </div>
        </form>
    </div>
</div>
<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>